/**
 * Copyright (c) 2016-2019 九点科技 All rights reserved.
 *
 * http://www.9dyun.cn
 *
 * 版权所有，侵权必究！
 */
package com.dian.modules.sale.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dian.common.utils.ListUtils;
import com.dian.common.utils.MapUtils;
import com.dian.modules.sale.dao.OrderLineDao;
import com.dian.modules.sale.entity.OrderHeadEntity;
import com.dian.modules.sale.entity.OrderLineEntity;
import com.dian.modules.sale.service.OrderLineService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 销售订单明细表服务实现类
 *
 * @author xiaolai
 * @email xiaolai@9dyun.cn
 * @date 2019-06-18 16:59:32
 */
@Service("OrderLineService")
public class OrderLineServiceImpl extends ServiceImpl<OrderLineDao, OrderLineEntity> implements OrderLineService {
    @Autowired
    public OrderLineService orderLineService;

    protected Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public boolean updateInfo(OrderHeadEntity orderHeadEntity) {
        List<OrderLineEntity> lineList=orderHeadEntity.getOrderLineEntityList();
        //设置明细的主表ID
        ListUtils.setPropertyValue(lineList,"orderId",orderHeadEntity.getId());
        this.removeByMap(new MapUtils().put("order_id", orderHeadEntity.getId()));
        this.saveBatch(lineList);
        return true;

    }

    @Override
    public boolean deleteInfo(Long id) {
        return this.remove(new QueryWrapper<OrderLineEntity>().eq("order_id",id));

    }

    @Override
    public List<OrderLineEntity> queryLineList(Long id) {
        return this.list(new QueryWrapper<OrderLineEntity>().eq("order_id",id));

    }

}
